#include <string>
#include <vector>

using  namespace std;

class Solution {
public:
	string longestCommonPrefix(vector<string>& strs) {
		if (strs.size() == 0) return "";
		if (strs.size() == 1) return strs[0];
		string ans;
		for (int k = 0; k < strs[0].size(); k++) {
			for (int i = 0; i < strs.size() - 1; i++) {
				if (strs[i + 1].size() > k&& strs[i][k] == strs[i + 1][k])
					continue;
				else
					return ans;
			}
			ans += strs[0][k];
		}

		return ans;
	}
};


//int main() {
//	Solution s;
//
//}